<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/actions/Action.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/actions/Response.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/entities/Person.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/utils/Logger.php';

final class LogoutAction extends Action {
	protected function accessIdentities() {
		return null;
	}

	protected function execute(Response $response) {
		if(isset($_SESSION['user'])) {
			$person = unserialize($_SESSION['user']);
			Logger::info('logout user "'.$person->getLogin().'"');
		}
		unset($_SESSION['year']);
		unset($_SESSION['user']);
		unset($_SESSION['menu']);
		session_destroy();
		$response->setActionPath('/login.html');
	}
}
?>